package com.kotlin.tsw.baselibrary.rx

import com.kotlin.tsw.baselibrary.common.ResultCode
import com.kotlin.tsw.baselibrary.data.protocol.BaseResp
import rx.Observable
import rx.functions.Func1

class BaseFuncBoolean<T> : Func1<BaseResp<T>, Observable<Boolean>> {
    override fun call(t: BaseResp<T>): Observable<Boolean> {
        return if (t.status != ResultCode.SUCCESS) {
            Observable.error(BaseException(t.status, t.message))
        } else {
            Observable.just(true)
        }
    }
}